home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / schematk / src_1152.lha / Doc.subproj / InteractionWin.m < prev    next >
Encoding:
Text File  |  1991-12-15  |  4.7 KB  |  169 lines

  1. /* Copyright รก 1991 Gustavus Adolphus College.  All rights reserved.
  2.  *
  3.  * Schematik was developed by Gustavus Adolphus College (GAC) with
  4.  * support from NeXT Computer, Inc.  Permission to copy this software,
  5.  * to redistribute it, and to use it for any purpose is granted,
  6.  * subject to the following restrictions and understandings.
  7.  *
  8.  * 1. Any copy made of this software must include this copyright
  9.  * notice in full.
  10.  *
  11.  * 2. Users of this software agree to make their best efforts (a) to
  12.  * return to the GAC Mathematics and Computer Science Department any
  13.  * improvements or extensions that they make, so that these may be
  14.  * included in future releases; and (b) to inform GAC of noteworthy
  15.  * uses of this software.
  16.  *
  17.  * 3. All materials developed as a consequence of the use of this
  18.  * software shall duly acknowledge such use, in accordance with the
  19.  * usual standards of acknowledging credit in academic research.
  20.  *
  21.  * 4. GAC makes no express or implied warranty or representation of
  22.  * any kind with respect to this software, including any warranty
  23.  * that the operation of this software will be error-free.  ANY
  24.  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
  25.  * PURPOSE IS HEREBY DISCLAIMED.  GAC is under no obligation to
  26.  * provide any services, by way of maintenance, update, or otherwise.
  27.  *
  28.  * 5. In conjunction with products arising from the use of this
  29.  * material, there shall be no use of the name of Gustavus Adolphus
  30.  * College nor of any adaptation thereof in any advertising,
  31.  * promotional, or sales literature without prior written consent
  32.  * from GAC in each case.
  33.  */
  34.  
  35. #import "InteractionWin.h"
  36. #import "../defines.h"
  37. #import DocText_h
  38. #import PrefAgent_h
  39. #import Main_h
  40. #import <appkit/Menu.h>
  41. #import <appkit/ScrollView.h>
  42. #import <appkit/TextFieldCell.h>
  43. #import <mach.h>
  44.  
  45. extern void *malloc(size_t);
  46. extern void free(void *);
  47. extern size_t strlen(const char *);
  48.  
  49. #define NIBFILE        "Interaction.nib"
  50. #define INTERZONENAME    "InterWin"
  51. #define MINIWINDOWICON    "Interaction"
  52. #define MINWINDOWHEIGHT    103
  53. #define MINWINDOWWIDTH    450
  54.  
  55. @implementation InteractionWin
  56.  
  57. + new
  58. {
  59.     NXRect r;
  60.     NXZone *zone = NXCreateZone(vm_page_size, vm_page_size, YES);
  61.  
  62. DEBUG_FUNC1(DEBUGLEVEL);
  63.     DEBUG_ASSERT(zone!=NULL)
  64.     self = LoadNIB(NIBFILE, self, zone); 
  65.     DEBUG_ASSERT(self!=nil)
  66.     docZone = zone;
  67.     NXNameZone(docZone, INTERZONENAME);
  68.     [self _newAuxiliary];
  69.     [[PrefAgent new] getInterFrame:&r];
  70.     [self placeWindow:&r];
  71.     [self setTitle:INTERWINDOWTITLE];
  72.     DEBUG_ASSERT(([self title]!=NULL)&&(*[self title]))
  73.     [self setMiniwindowIcon:MINIWINDOWICON];
  74.     DEBUG_ASSERT(([self miniwindowIcon]!=NULL)&&(*[self miniwindowIcon]))
  75.     [levelText setStringValue:LEVELTITLE];
  76.     DEBUG_ASSERT(([levelText stringValue]!=NULL)&&(*[levelText stringValue]))
  77.     return self;
  78. }
  79.  
  80. - setTitleAsFilename:(const char *)aString
  81. {
  82.     char *temp;
  83.     
  84.     [super setTitleAsFilename:aString];
  85.     temp = malloc(strlen([super title])+strlen(INTERWINDOWTITLE)+4);
  86.     sprintf(temp, "%s (%s)", INTERWINDOWTITLE, [super title]);
  87.     [super setTitle:temp];
  88.     free(temp);
  89.     return self;
  90. }
  91.  
  92. - setLevel:(int)anInt
  93. {
  94. DEBUG_FUNC1(DEBUGLEVEL);
  95.     return [levelField setIntValue:anInt];
  96. }
  97.  
  98. - setPrompt:(const char *)aString
  99. {
  100. DEBUG_FUNC1(DEBUGLEVEL);
  101.     return [promptField setStringValue:aString];
  102. }
  103.  
  104. @end
  105.  
  106. @implementation InteractionWin (Delegate)
  107.  
  108. - textDidGetKeys:sender isEmpty:(BOOL)flag
  109. {
  110. DEBUG_FUNC1(DEBUGLEVEL);
  111.     return [super setDocEdited:YES];
  112. }
  113.  
  114. - textWillConvert:sender fromFont:from toFont:to
  115. {
  116. DEBUG_FUNC1(DEBUGLEVEL);
  117.     [[PrefAgent new] setInterFont:to];
  118.     return to;
  119. }
  120.  
  121. - windowDidMove:sender
  122. {
  123.     NXRect r;
  124.  
  125. DEBUG_FUNC1(DEBUGLEVEL);
  126.     [super getFrame:&r];
  127.     return [[PrefAgent new] setInterFrame:&r];
  128. }
  129.  
  130. - windowDidResize:sender
  131. {
  132.     NXRect r;
  133.  
  134. DEBUG_FUNC1(DEBUGLEVEL);
  135.     [super getFrame:&r];
  136.     return [[PrefAgent new] setInterFrame:&r];
  137. }
  138.  
  139. - windowDidBecomeMain:sender
  140. {
  141. DEBUG_FUNC1(DEBUGLEVEL);
  142.     DisableMenuItem(FindMenuCell2(MENU_DOCUMENT, MENU_DOCUMENT_Close));
  143.     DisableMenuItem(FindMenuCell2(MENU_WINDOWS, MENU_WINDOWS_Close));
  144.     if (![[PrefAgent new] evaluateAll])
  145.       DisableMenuItem(FindMenuCell2(MENU_ACTIONS, MENU_ACTIONS_EvalAll));
  146.     return self;
  147. }
  148.  
  149. - windowDidResignMain:sender
  150. {
  151. DEBUG_FUNC1(DEBUGLEVEL);
  152.     EnableMenuItem(FindMenuCell2(MENU_DOCUMENT, MENU_DOCUMENT_Close));
  153.     EnableMenuItem(FindMenuCell2(MENU_WINDOWS, MENU_WINDOWS_Close));
  154.     EnableMenuItem(FindMenuCell2(MENU_ACTIONS, MENU_ACTIONS_EvalAll));
  155.     return self;
  156. }
  157.  
  158. - windowWillResize:sender toSize:(NXSize *)frameSize
  159. {
  160. DEBUG_FUNC1(DEBUGLEVEL);
  161.     if (frameSize->width<MINWINDOWWIDTH)
  162.       frameSize->width = MINWINDOWWIDTH;
  163.     if (frameSize->height<MINWINDOWHEIGHT)
  164.       frameSize->height = MINWINDOWHEIGHT;
  165.     return self;
  166. }
  167.  
  168. @end
  169.